```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>设计模式解析：策略模式 vs 状态模式</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4, .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight {
            position: relative;
            z-index: 1;
        }
        .highlight:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(118, 75, 162, 0.2);
            z-index: -1;
            transform: scaleX(1.05);
            transform-origin: left;
            transition: transform 0.3s ease;
        }
        .highlight:hover:after {
            transform: scaleX(1.1);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-10 lg:px-20">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4 leading-tight">设计模式解析</h1>
                    <h2 class="text-2xl md:text-3xl font-semibold mb-6">策略模式 vs 状态模式</h2>
                    <p class="text-lg opacity-90 mb-8">探索行为设计模式的精髓，理解它们如何优雅地解决软件开发中的复杂问题。</p>
                    <div class="flex space-x-4">
                        <a href="#strategy" class="px-6 py-3 bg-white text-indigo-800 font-medium rounded-lg hover:bg-opacity-90 transition-all">
                            <i class="fas fa-chess mr-2"></i>策略模式
                        </a>
                        <a href="#state" class="px-6 py-3 bg-indigo-900 bg-opacity-50 text-white font-medium rounded-lg hover:bg-opacity-70 transition-all">
                            <i class="fas fa-sync-alt mr-2"></i>状态模式
                        </a>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white bg-opacity-10 p-6 rounded-xl backdrop-blur-sm border border-white border-opacity-20">
                        <div class="mermaid">
                            graph TD
                            A[行为设计模式] --> B[策略模式]
                            A --> C[状态模式]
                            B --> D[算法封装]
                            B --> E[运行时选择]
                            B --> F[相互独立]
                            C --> G[状态封装]
                            C --> H[行为变化]
                            C --> I[状态转换]
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-6xl py-16 px-4 md:px-10 lg:px-20">
        <!-- Strategy Pattern Section -->
        <section id="strategy" class="mb-20">
            <div class="flex items-center mb-12">
                <div class="w-12 h-12 bg-indigo-600 text-white rounded-lg flex items-center justify-center mr-4">
                    <i class="fas fa-chess text-2xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">策略模式<br><span class="text-xl font-medium text-indigo-600">(Strategy Pattern)</span></h2>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8 mb-12">
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-box-open text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">算法的封装</h3>
                    <p class="text-gray-600">各种算法被封装在独立的策略类中，符合开闭原则。系统可以在不修改原有代码的情况下灵活扩展新的算法。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-random text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">动态选择</h3>
                    <p class="text-gray-600">客户端可以在运行时选择适当的策略，实现灵活的行为变更。这使得系统能够根据不同的需求或条件切换不同算法。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-project-diagram text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">相互独立</h3>
                    <p class="text-gray-600">不同策略之间相互独立，互不干扰。每个策略类只关注自己的算法实现，便于单独维护和测试。</p>
                </div>
            </div>
            
            <div class="bg-indigo-50 border-l-4 border-indigo-600 p-6 rounded-r-lg mb-8">
                <h3 class="text-xl font-semibold mb-4 text-indigo-800"><i class="fas fa-lightbulb mr-2"></i>适用场景</h3>
                <ul class="space-y-3">
                    <li class="flex items-start">
                        <span class="text-indigo-600 mr-2">•</span>
                        <span><span class="font-medium">多种算法选择</span> - 当系统有多个可互换的算法或行为时，例如排序算法、支付方式等。</span>
                    </li>
                    <li class="flex items-start">
                        <span class="text-indigo-600 mr-2">•</span>
                        <span><span class="font-medium">消除条件语句</span> - 当算法的选择逻辑复杂，使用策略模式可以减少条件语句，提高可读性。</span>
                    </li>
                    <li class="flex items-start">
                        <span class="text-indigo-600 mr-2">•</span>
                        <span><span class="font-medium">算法变动频繁</span> - 适合在运行时需要灵活切换算法的场景，如用户可以选择不同的排序方式。</span>
                    </li>
                </ul>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200">
                <div class="mermaid">
                    classDiagram
                    class Context {
                        -strategy: Strategy
                        +setStrategy(Strategy)
                        +executeStrategy()
                    }
                    interface Strategy {
                        <<interface>>
                        +execute()
                    }
                    class ConcreteStrategyA {
                        +execute()
                    }
                    class ConcreteStrategyB {
                        +execute()
                    }
                    Context o-- Strategy
                    Strategy <|.. ConcreteStrategyA
                    Strategy <|.. ConcreteStrategyB
                </div>
            </div>
        </section>
        
        <!-- State Pattern Section -->
        <section id="state" class="mb-20">
            <div class="flex items-center mb-12">
                <div class="w-12 h-12 bg-purple-600 text-white rounded-lg flex items-center justify-center mr-4">
                    <i class="fas fa-sync-alt text-2xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">状态模式<br><span class="text-xl font-medium text-purple-600">(State Pattern)</span></h2>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8 mb-12">
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="text-purple-600 mb-4">
                        <i class="fas fa-layer-group text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">状态的封装</h3>
                    <p class="text-gray-600">每种状态对应一个状态类，这些状态类实现相同的状态接口。状态相关的行为被封装在相应的状态类中。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="text-purple-600 mb-4">
                        <i class="fas fa-exchange-alt text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">行为的变化</h3>
                    <p class="text-gray-600">对象的行为与其状态密切相关，当状态改变时，对象的行为也随之改变。这使得对象能够动态响应状态变化。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="text-purple-600 mb-4">
                        <i class="fas fa-sitemap text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">简化状态管理</h3>
                    <p class="text-gray-600">状态转换逻辑可以集中管理，减少了条件判断的复杂性。每个状态类只关注自己的行为，便于维护和扩展。</p>
                </div>
            </div>
            
            <div class="bg-purple-50 border-l-4 border-purple-600 p-6 rounded-r-lg mb-8">
                <h3 class="text-xl font-semibold mb-4 text-purple-800"><i class="fas fa-lightbulb mr-2"></i>适用场景</h3>
                <ul class="space-y-3">
                    <li class="flex items-start">
                        <span class="text-purple-600 mr-2">•</span>
                        <span><span class="font-medium">对象的行为依赖于状态</span> - 当对象的行为在不同状态下显著不同，例如订单的不同处理状态（待付款、已付款、已发货）。</span>
                    </li>
                    <li class="flex items-start">
                        <span class="text-purple-600 mr-2">•</span>
                        <span><span class="font-medium">复杂状态管理</span> - 当对象的状态转换复杂且频繁时，使用状态模式可以有效管理状态及其转换。</span>
                    </li>
                    <li class="flex items-start">
                        <span class="text-purple-600 mr-2">•</span>
                        <span><span class="font-medium">封装状态逻辑</span> - 当需要将状态转换的逻辑和相关行为分开时，适合使用状态模式。</span>
                    </li>
                </ul>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200">
                <div class="mermaid">
                    classDiagram
                    class Context {
                        -state: State
                        +setState(State)
                        +request()
                    }
                    interface State {
                        <<interface>>
                        +handle()
                    }
                    class ConcreteStateA {
                        +handle()
                    }
                    class ConcreteStateB {
                        +handle()
                    }
                    Context o-- State
                    State <|.. ConcreteStateA
                    State <|.. ConcreteStateB
                </div>
            </div>
        </section>
        
        <!-- Comparison Section -->
        <section class="bg-white rounded-xl shadow-md overflow-hidden">
            <div class="bg-gradient-to-r from-indigo-600 to-purple-600 p-6 text-white">
                <h2 class="text-2xl font-bold"><i class="fas fa-balance-scale mr-3"></i>策略模式与状态模式的区别</h2>
            </div>
            <div class="p-6">
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-gray-50 p-5 rounded-lg">
                        <h3 class="text-lg font-semibold mb-3 text-indigo-800">目的不同</h3>
                        <p>策略模式主要用于在运行时选择不同的算法或行为，而状态模式用于根据对象的状态变化来改变对象的行为。</p>
                    </div>
                    <div class="bg-gray-50 p-5 rounded-lg">
                        <h3 class="text-lg font-semibold mb-3 text-purple-800">结构和实现</h3>
                        <p>策略模式通过上下文类持有策略接口的引用，允许动态选择算法。状态模式则通过状态类持有状态接口的引用，根据状态变化动态改变行为。</p>
                    </div>
                    <div class="bg-gray-50 p-5 rounded-lg">
                        <h3 class="text-lg font-semibold mb-3 text-gray-800">状态与行为的关系</h3>
                        <p>在策略模式中，行为是相对独立的，可以在运行时自由切换；在状态模式中，行为依赖于对象的当前状态，状态的变化直接影响对象的行为。</p>
                    </div>
                </div>
                
                <div class="mt-8">
                    <div class="mermaid">
                        flowchart LR
                        subgraph 策略模式
                        direction TB
                        A[上下文] -->|持有| B[策略接口]
                        B --> C[具体策略A]
                        B --> D[具体策略B]
                        end
                        subgraph 状态模式
                        direction TB
                        E[上下文] -->|持有| F[状态接口]
                        F --> G[具体状态A]
                        F --> H[具体状态B]
                        G -->|状态转换| H
                        H -->|状态转换| G
                        end
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4">
        <div class="container mx-auto max-w-6xl text-center">
            <div class="mb-6">
                <h3 class="text-xl font-medium text-white mb-2">技术小馆</h3>
                <p class="text-gray-400">探索编程艺术，解密设计模式</p>
            </div>
            <div class="mb-6">
                <a href="http://www.yuque.com/jtostring" class="text-indigo-400 hover:text-indigo-300 transition-colors">
                    <i class="fas fa-external-link-alt mr-2"></i>www.yuque.com/jtostring
                </a>
            </div>
            <div class="flex justify-center space-x-6">
                <a href="#" class="text-gray-400 hover:text-white transition-colors">
                    <i class="fab fa-github text-xl"></i>
                </a>
                <a href="#" class="text-gray-400 hover:text-white transition-colors">
                    <i class="fab fa-twitter text-xl"></i>
                </a>
                <a href="#" class="text-gray-400 hover:text-white transition-colors">
                    <i class="fab fa-linkedin text-xl"></i>
                </a>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            securityLevel: 'loose'
        });
    </script>
</body>
</html>
```